package linkedlist;

import treesNgraphs.TreeNode;

/**
 * Created by Tzachi on 08/10/2014.
 */
public class Node<E> {
    private E data;
    private Node next;

    public Node(E data) {
        this.data = data;
    }

    public void setNext(Node<E> next) {
        this.next = next;
    }

    public Node chainNext(Node next) {
        this.next = next;
        return this.next;
    }

    public void setData(E data) {
        this.data = data;
    }

    public E getData() {
        return data;
    }

    public Node<E> getNext() {
        return next;
    }

    @Override
    public String toString() {
        return "Node{" +
                "data=" + data +
                '}';
    }

    public void printChain(){
        Node current = this;
        do{
            System.out.print(current.getData() + "--->");
            current = current.next;
        } while (current != null);
        System.out.println();
    }
}
